$.mcCube.tools = {};
$.mcCube.tools.reloadPage = function(){
    location.assign(location.href);
}
$.mcCube.tools.ajax = function(type, url, callback, datasToSend){
    $.ajax({
        type    : type,
        url     : url,
        data    : datasToSend,
        success : function(data) {
            callback(data);
        },
        complete : function(xhr) {
            $.mcCube.tools.ajax.onComplete(xhr);
        }
    });
}
$.mcCube.tools.ajax.onComplete = function(xhr){
    var reloadPage = xhr.getResponseHeader('RELOADPAGE');
    if(reloadPage)
        $.mcCube.tools.reloadPage();

    var errors = xhr.getResponseHeader('SERVERERRORS');
    if(errors)
        $.mcCube.notice.error(errors);
}
$.mcCube.tools.ajax.post = function(url, callback, datasToSend){
    $.mcCube.tools.ajax('post', url, callback, datasToSend);
}
$.mcCube.tools.ajax.get = function(url, callback, datasToSend){
    $.mcCube.tools.ajax('get', url, callback, datasToSend);
}